package com.hframe.plugin.ronglian;


import com.hframe.data.DRef;
import com.hframe.type.TLong;
import com.hframe.type.TString;
import org.apache.log4j.Logger;

public class RongLianConfig extends DRef<RongLianConfig> {
    private static Logger log = Logger.getLogger(RongLianConfig.class);

    private TLong Period = new TLong((long) 10);
    private TString SMST = new TString("debug,1");
    private TString AppID = new TString("aaf98f89521153040152147e80040481");
    private TString Token = new TString("dfed285b03164cde8e4bd9b9a8887465");
    private TString SID = new TString("8a48b55152114d540152147d429f048c");
    private TString URL = new TString("sandboxapp.cloopen.com");
    private TString Port = new TString("8883");
    private TString SpeechCount = new TString("3");
    private TString SpeechPhone = new TString("");

    /**
     * 获得蓉联通信语音验证播报次数，默认为3次
     */
    public String getSpeechCount() {
        return SpeechCount.get();
    }

    /**
     * 获得蓉联通信语音验证来电显示号码，默认为空
     */
    public String getSpeechPhone() {
        return SpeechPhone.get();
    }

    /**
     * 蓉联通信短信验证的有效时间，默认为1分钟
     */
    public long getPeriod() {
        return Period.get();
    }

    /**
     * 获得蓉联云通讯验证短信模板ID
     *
     * @param key 短信模板的应用标识
     * @return 返回模板ID
     */
    public String getSMST(String key) {
        String[] sms = this.SMST.get().split(",");
        for (int i = 0; i < sms.length; i += 2) {
            if (sms[i].equals(key) && (i + 1) < sms.length) {
                return sms[i + 1];
            }
        }
        return sms[1];
    }

    /**
     * 获得蓉联云通讯APPID
     *
     * @return
     */
    public String getAppID() {
        return AppID.get();
    }

    /**
     * 获得蓉联云通讯认证令牌(AUTH TOKEN)
     *
     * @return
     */
    public String getToken() {
        return Token.get();
    }

    /**
     * 获得蓉联云通讯账号ID(ACCOUNTID)
     *
     * @return
     */
    public String getSID() {
        return SID.get();
    }

    /**
     * 获得蓉联云通讯接口地址
     *
     * @return
     */
    public String getURL() {
        return URL.get();
    }

    /**
     * 获得蓉联云通讯接口地址端口号
     *
     * @return
     */
    public String getPort() {
        return this.Port.get();
    }

    public static Logger Log() {
        return log;
    }

    public TLong Period() {
        return Period;
    }

    public TString SMST() {
        return SMST;
    }

    public TString AppID() {
        return AppID;
    }

    public TString Token() {
        return Token;
    }

    public TString SID() {
        return SID;
    }

    public TString URL() {
        return URL;
    }

    public TString Port() {
        return Port;
    }

    public TString SpeechCount() {
        return SpeechCount;
    }

    public TString SpeechPhone() {
        return SpeechPhone;
    }

}
